//
//  SettingArrowView.swift
//  BasicTools
//
//  Created by ikang on 2025/8/26.
//

import SwiftUI

struct SettingArrowView: View {
    @Bindable var itemModel: SettingItemModel
    var isShowLine: Bool = false
    
    var body: some View {
        HStack(spacing: SettingModel.shared.itemHSpace) { 
            if !itemModel.leftImage.isEmpty {
                Image(itemModel.leftImage)
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .frame(width: SettingModel.shared.leftImageSize.width, height: SettingModel.shared.leftImageSize.height)
            }
            
            if itemModel.type == .titleHStack {
                if !itemModel.title.isEmpty {
                    Text(itemModel.title)
                        .font(SettingModel.shared.titleFont)
                        .foregroundStyle(SettingModel.shared.titleColor)
                }
                
                Spacer()
                
                if !itemModel.subTitle.isEmpty {
                    Text(itemModel.subTitle)
                        .font(SettingModel.shared.subTitleFont)
                        .foregroundStyle(SettingModel.shared.subTitleColor)
                }
            }else if itemModel.type == .titleVStack {
                VStack(spacing: SettingModel.shared.itemTitleSpace) { 
                    if !itemModel.title.isEmpty {
                        Text(itemModel.title)
                            .font(SettingModel.shared.titleFont)
                            .foregroundStyle(SettingModel.shared.titleColor)
                    }
                    
                    if !itemModel.subTitle.isEmpty {
                        Text(itemModel.subTitle)
                            .font(SettingModel.shared.subTitleFont)
                            .foregroundStyle(SettingModel.shared.subTitleColor)
                    }
                }
                
                Spacer()
            }
            
            
            if !itemModel.rightImage.isEmpty {
                Image(itemModel.rightImage)
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .frame(width: SettingModel.shared.rightImageSize.width, height: SettingModel.shared.rightImageSize.height)
            }
        }
        .padding(SettingModel.shared.itemPadding)
        .bt.lineModifier(lineHeight: SettingModel.shared.itemLineHeight, 
                         backgroundColor: SettingModel.shared.itemLineColor, 
                         padding: SettingModel.shared.itemLinePadding, 
                         isShowLine: isShowLine)
    }
}

//#Preview {
//    SwiftUIView()
//}
